package controllers

import (
	//"fmt"
	"net/http"

	"github.com/gin-gonic/gin"

	"huaxrobot/services"
)

type performancedata struct {
	Id    string   `json:"id"`
}


type perconfigdata struct {
	InterfaceName              string         `json:"interfacename"`
	TestId					string         `json:"testid"`
	MaxUsers                  string         `json:"maxusers"`
	AvgThroughput                 string         `json:"avgthroughput"`	
	Errors                    string		 `json:"errors"`
	AvgResponseTime              string        `json:"avgResponsetime"`
	ResponseTime90              string         `json:"responsetime90"`
	AvgBandwidth              string         `json:"avgbandwidth"`
	AvgTransactions             string         `json:"avgtransactions"`
    
}

func PerformanceAdd(c *gin.Context) {
	datainfo := performancedata{}
	err := c.ShouldBindJSON(&datainfo)
	if err != nil {
		c.JSON(http.StatusBadRequest, "参数错误")
		return
	}
	id := datainfo.Id	
	res := services.PerformanceAdd(id)
	c.JSON(http.StatusOK, res)
}



func PerformanceConfigAdd(c *gin.Context) {
	datainfo := perconfigdata{}
	err := c.ShouldBindJSON(&datainfo)
	if err != nil {
		c.JSON(http.StatusBadRequest, "参数错误")
		return
	}
	interfacename := datainfo.InterfaceName
	testid := datainfo.TestId
	res := services.PerformanceConfigAdd(interfacename, testid)
	c.JSON(http.StatusOK, res)
}

func PerformanceConfigListGet(c *gin.Context) {	
	res := services.PerformanceConfigListGet()
	c.JSON(http.StatusOK, res)
}